<template>
  <div>
    <slot name="label"></slot>
    <el-select size="mini" multiple filterable placeholder="请选择"
      v-model="value" @change="handleChange($event)">
      <el-option v-for="item in postParams.FROMSOURCES"
        :key="item.id" :label="item.name" :value="item.id">
        {{item.name}}
        <small style="color:red" v-if="isDev">{{item.id}}</small>
      </el-option>
    </el-select>
    {{postParams.crmCfg.fromSources}}
  </div>
</template>

<script>
import { mapState, mapMutations } from 'vuex';
export default {
  name:'fromSources',//资源渠道
  computed: {
    ...mapState([
      'resetParams',
      'postParams',
      'fromSources',
    ]),
  },
  watch: {
    resetParams:function(nv,ov){
      console.log(nv,ov);
      this.value.splice(0,this.value.length)
      
    }
  },
  data() {
    return {
      isDev: process.env.NODE_ENV == 'development',
      value:[],
    };
  },
  methods: {
    handleClose(done) {},
    handleChange(){
      this.updata2Store()
    },
    updata2Store:function(){
      let v = this.$_.cloneDeep(this.value).join(',')
      this.$store.commit('postParams/setCRMcfgKeyValue',{
        key:'fromSources',value:v
      })
    },
  }
};
</script>

<style>

</style>